﻿using System;
using System.Web.UI.WebControls;
using Ue.Framework.Web;
using Ue.Infrastructure.DomainBase;
using Ue.Infrastructure.RepositoryFramework;
using Ue.Infrastructure.Web.UI;
using Ue.Qcdz.Domain.Shops;
namespace Ue.Qcdz.UI.Controls
{
    public class ShopGridView : SkinnedGridView, IShopDataQuery, Ue.Infrastructure.DomainBase.ISort
    {
        private IShopRepository repository;
        public ShopGridView()
        {
            this.repository = RepositoryFactory.GetRepository<IShopRepository, Shop>();
        }
        protected override void GridViewDataBind(object sender, EventArgs args)
        {
            IDataResult<Shop> dataResult = this.repository.FindBy(this);

            Repeater repeater = sender as Repeater;
            repeater.DataSource = dataResult.DataObjects;
            repeater.DataBind();
            this.RecordCount = dataResult.RecordCount;
        }

        protected override string GetSkinFileName()
        {
            return "~/Admin/Themes/Skins/Shops/Shop.ascx";
        }

        #region IShopDataQuery 成员
        private string _Name;
        public string Name
        {
            get
            {
                if (string.IsNullOrEmpty(this._Name))
                {
                    return this.Page.Request.GetQueryValue<string>("Name");
                }
                return this._Name;
            }
            set
            {
                this._Name = value;
            }

        }
        private bool _IsTop;
        public bool IsTop
        {
            get
            {
                if (this._IsTop == false)
                    return Page.Request.GetQueryValue<bool>("IsTop");
                return this._IsTop;
            }
            set
            {
                this._IsTop = value;
            }
        }

        public bool Status
        {
            get;
            set;
        }

        #endregion

        #region ISort 成员

        public string BuildSortStatement()
        {
            return "CreateOn DESC";
        }

        #endregion
    }
}
